package com.pansoft.openplanet.adapter;

import android.widget.ImageView;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.efounder.chat.model.AppConstant;
import com.efounder.chat.utils.LXGlideImageLoader;
import com.pansoft.openplanet.R;
import com.pansoft.openplanet.bean.AllAppTabItemBean;

import java.util.List;

/**
 * @author : zzj
 * @e-mail : zhangzhijun@pansoft.com
 * @date : 2019/4/22 11:15
 * @desc : 全部应用的adapter
 * @version: 1.0
 */
public class AssetAllAppAdapter extends BaseSectionQuickAdapter<AllAppTabItemBean, BaseViewHolder> {
    /**
     * 是否显示加减号
     */
    private boolean isShow;
    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param layoutResId      The layout resource id of each item.
     * @param sectionHeadResId The section head layout id for each item
     * @param data             A new list is created out of this one to avoid mutable list
     */
    public AssetAllAppAdapter(int layoutResId, int sectionHeadResId, List<AllAppTabItemBean> data,boolean isShow) {
        super(layoutResId, sectionHeadResId, data);
        this.isShow = isShow;
    }

    @Override
    protected void convertHead(BaseViewHolder helper, AllAppTabItemBean item) {
        helper.setText(R.id.tv_title,item.header);
    }

    @Override
    protected void convert(BaseViewHolder helper, AllAppTabItemBean item) {
        helper.setText(R.id.tv_title,item.t.getName());
        String filepath = AppConstant.APP_ROOT + "/res/unzip_res/menuImage/" + item.t.getIcon();
        LXGlideImageLoader.getInstance().displayImage(mContext, (ImageView) helper.getView(R.id.iv_pic),
                "file://" + filepath);
        if(isShow){
            helper.setGone(R.id.iv_operation_app,true);
        }else {
            helper.setGone(R.id.iv_operation_app,false);
        }
        if(item.t.isShow()){
            helper.setImageResource(R.id.iv_operation_app,R.drawable.ic_asset_edit_app_minus);
        }else {
            helper.setImageResource(R.id.iv_operation_app,R.drawable.ic_asset_edit_app_add);


        }
        helper.addOnClickListener(R.id.iv_operation_app);
    }
}
